import {createStore} from "vuex"
import {getStorage, setStorage, clearStorage} from "@/utils/storage";
import {userState, userGetters, userMutations, userActions} from "@/store/modules/user";
import {tabState, tabGetters, tabMutations, tabActions} from "@/store/modules/tab";

export default createStore({
  state: {
    ...userState,
    ...tabState,
    routeList: []
  },
  getters: {
    ...userGetters,
    ...tabGetters,
    routes: (state) => state.routeList
  },
  mutations: {
    ...userMutations,
    ...tabMutations,
    SET_ROUTES(state, val) {
      state.routeList = val
      setStorage("routes", val)
    },
    GET_ROUTES(state) {
      if (getStorage("routes")) {
        state.routeList = getStorage("routes")
      }
    }
  },
  actions: {
    ...userActions,
    ...tabActions
  },
  modules: {}
})
